using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Practices.CompositeUI;
using Microsoft.Practices.ObjectBuilder;
using SCSFContrib.CompositeUI.WPF.Activation;
using SCSFContrib.CompositeUI.WPF.BuilderStrategies;

namespace SCSFContrib.CompositeUI.WPF.Visualizer
{
	/// <summary>
	/// Implements a <see cref="CabVisualizer"/> for WPF CAB applications.
	/// </summary>
	public class WindowsVisualizer : CabVisualizer
	{
		/// <summary>
		/// Adds any builder strategies required by the <c>WindowsVisualizer</c>.
		/// </summary>
		/// <param name="builder">
		/// The builder to which strategies can be added.
		/// </param>
		protected override void AddBuilderStrategies(Builder builder)
		{
			base.AddBuilderStrategies(builder);
			builder.Strategies.AddNew<WindowsServiceStrategy>(BuilderStage.Initialization);
			builder.Strategies.AddNew<FrameworkElementActivationStrategy>(BuilderStage.Initialization);
			builder.Strategies.AddNew<FrameworkContentElementActivationStrategy>(BuilderStage.Initialization);
			builder.Strategies.AddNew<FrameworkElementSmartPartStrategy>(BuilderStage.Initialization);
		}

		/// <summary>
		/// Adds any services required by the <c>WindowsVisualizer</c>.
		/// </summary>
		protected override void AddServices()
		{
			base.AddServices();
			RootWorkItem.Services.AddNew<FrameworkElementActivationService, IFrameworkElementActivationService>();
			RootWorkItem.Services.AddNew<FrameworkContentElementActivationService, IFrameworkContentElementActivationService>();
		}

		/// <summary>
		/// Creates the visualizer shell used by the <c>WindowsVisualizer.</c>
		/// </summary>
		protected override void CreateVisualizationShell()
		{
			base.CreateVisualizationShell();
			RootWorkItem.Items.AddNew<VisualizerWindow>("VisualizerWindow").Show();
		}
	}
}